window.onload = function () {
    var oAll = document.getElementById(".map");
    var oUl = document.querySelector(".map_txr ul");
    var oOl = document.querySelector(".map ol");
    //1.拿到第一张图片。克隆一张追加到最后一张
    var cloneLi = oUl.children[0].cloneNode(true);
    oUl.appendChild(cloneLi);
//创建小格子
    for (var i = 0; i < oUl.children.length - 1; i++) {
        var newLi = document.createElement("li");
        if (i == 0) {
            newLi.className = "current";
        }
        // newLi.innerText=(i+1);
        newLi.tmpIndex = i;
        oOl.appendChild(newLi)
        newLi.onclick = function () {
            imgIndex = dianIndex = this.tmpIndex - 1;
            autoPlay();
        }

    }
    //自动播放轮播图
    var timer = setInterval(autoPlay, 3000)
    var imgIndex = 0;
    var dianIndex = 0;

    function autoPlay() {
        imgIndex++;
        if (imgIndex > 5) {
            oUl.style.left = "0px";
            imgIndex = 1;
        }
        animate(oUl, {left: -imgIndex * 1920})
        //点同步
        dianIndex++;
        if (dianIndex > 4) {
            dianIndex = 0;
        }
        for (var i = 0; i < oOl.children.length; i++) {
            oOl.children[i].className = "";
        }
        oOl.children[dianIndex].className = "current";
    }

    //鼠标移入暂停
    oUl.onmouseenter = function () {
        clearInterval(timer)
    }
    //鼠标离开 继续轮播
    oUl.onmouseleave = function () {
        timer = setInterval(autoPlay, 3000);
    }
    oOl.onmouseenter = function () {
        clearInterval(timer)
    }
    //鼠标离开 继续轮播
    oOl.onmouseleave = function () {
        timer = setInterval(autoPlay, 3000);
    };
    var oAll1 = document.querySelector(".map_center_btm_left");
    var oUl1 = document.querySelector(".map_center_btm_left>ul");
    var oOl1 = document.querySelector(".map_center_btm_left>ol");
    var cloneLi1 = oUl1.children[0].cloneNode(true);
    oUl1.appendChild(cloneLi1);
    for (var i = 0; i < oUl1.children.length; i++) {
        var newLi1 = document.createElement("li");
        if (i == 0) {
            newLi1.className = "current1";
        }
        newLi1.temIndex = i;
        oOl1.appendChild(newLi1)
        newLi1.onclick = function () {
            imgIndex1 = dianIndex1 = this.temIndex - 1;
            autoPlay1();
        }
    }
//自动播放轮播图
    var timer1 = setInterval(autoPlay1, 5000)
    var imgIndex1 = 0;
    var dianIndex1 = 0;

    function autoPlay1() {
        imgIndex1++;
        if (imgIndex1 > 10) {
            oUl1.style.left = "0px";
            imgIndex1 = 0;
        }
        animate(oUl1, {left: -imgIndex1 * 400})
        //点同步
        dianIndex1++;

        if (dianIndex1 > 10) {
            dianIndex1 = 0;
        }
        for (var i = 0; i < oOl1.children.length; i++) {
            oOl1.children[i].className = "";
        }
        oOl1.children[dianIndex1].className = "current1";
    }

    //鼠标移入暂停
    oUl1.onmouseover = function () {
        clearInterval(timer1)
    }
    //鼠标离开 继续轮播
    oUl1.onmouseout = function () {
        timer1 = setInterval(autoPlay1, 5000);
    }
    //鼠标移入暂停
    oOl1.onmouseenter = function () {
        clearInterval(timer1)
    }
    //鼠标离开 继续轮播
    oOl1.onmouseleave = function () {
        timer1 = setInterval(autoPlay1, 5000);
    }

}
